using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using Utils;

public class GameOverPanel : MonoBehaviour
{
    private Button restartBtn, exitBtn;

    private void Awake()
    {
        restartBtn = UITool.GetComponent<Button>("Btns/RestartBtn", gameObject);
        exitBtn = UITool.GetComponent<Button>("Btns/ExitBtn", gameObject);
        AddButtonClickEvent();
    }

    private void OnDestroy()
    {
        restartBtn.onClick.RemoveListener(OnClickRestartBtn);
        exitBtn.onClick.RemoveListener(OnClickExitBtn);
    }


    private void AddButtonClickEvent()
    {
        restartBtn.onClick.AddListener(OnClickRestartBtn);
        exitBtn.onClick.AddListener(OnClickExitBtn);
    }

    private void OnClickRestartBtn()
    {
        GameController.Instance().Restart();
    }

    private void OnClickExitBtn()
    {
        GameController.Instance().Exit();
        Destroy(gameObject);
    }
}
